package com.yn.common.vo;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yn.common.model.article.ArticleContent;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="ArticleInfoVO对象", description="转运相关文章信息返回对象")
public class ArticleInfoVO {
    @ApiModelProperty(value = "文章ID")
    private Long id;

    @ApiModelProperty(value = "栏目id")
    private Long titleManageId;

    @ApiModelProperty(value = "栏目名称字符串")
    private String titleManageName;

    @ApiModelProperty(value = "栏目类型")
    private String titleType;

    @ApiModelProperty(value = "栏目类型字典值")
    private String titleTypeStr;

    @ApiModelProperty(value = "文章标题")
    private String articleTitle;

    @ApiModelProperty(value = "文章来源")
    private String articleSource;

    @ApiModelProperty(value = "文章内容")
    private String articleContent;

    @ApiModelProperty(value = "文章发布时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
    private Date releaseTime;

    public static ArticleInfoVO transform(ArticleContent articleContent) {
        if (ObjectUtil.isNull(articleContent)) {
            return null;
        }
        ArticleInfoVO articleInfoVO = new ArticleInfoVO();
        BeanUtil.copyProperties(articleContent, articleInfoVO);

        return articleInfoVO;
    }

}
